package form.ui.component.Input {
	import flash.display.DisplayObject;
	
	import form.ui.assets.Compiled;
	import form.ui.core.FMSprite;

	public class InputOutline extends FMSprite {
		private var _focus:DisplayObject;
		private var _blur:DisplayObject;
		private var _disabled:DisplayObject;
		
		public function InputOutline() {
			super();
			
			this.focus = new Compiled.InputOutlineFocus();
			this.blur = new Compiled.InputOutlineBlur();
			this.disabled = new Compiled.InputOutlineDisabled();
			
			this.mouseEnabled = false;
			this.mouseChildren = false;
			
			this.showBlur();
		}
		
		public override function set width(value:Number):void {
			super.width = value;
			
			this.focus.width = this.width;
			this.blur.width = this.width;
			this.disabled.width = this.width;
		}
		
		public override function set height(value:Number):void {
			super.height = value;
			
			this.focus.height = this.height;
			this.blur.height = this.height;
			this.disabled.height = this.height;
		}
		
		public function showFocus():void {
			this.focus.visible = true;
			this.blur.visible = false;
			this.disabled.visible = false;
		}
		
		public function showBlur():void {
			this.focus.visible = false;
			this.blur.visible = true;
			this.disabled.visible = false;
		}
		
		public function showDisabled():void {
			this.focus.visible = false;
			this.blur.visible = false;
			this.disabled.visible = true;
		}
		
		protected function set focus(value:DisplayObject):void {
			if (this._focus != null) {
				this.removeChild(this._focus);
			}
			
			this._focus = value;
			this.addChild(this.focus);
		}
		
		protected function get focus():DisplayObject {
			return this._focus;
		}
		
		protected function set blur(value:DisplayObject):void {
			if (this._blur != null) {
				this.removeChild(this._blur);
			}
			
			this._blur = value;
			this.addChild(this.blur);
		}
		
		protected function get blur():DisplayObject {
			return this._blur;
		}
		
		protected function set disabled(value:DisplayObject):void {
			if (this._disabled != null) {
				this.removeChild(this._disabled);
			}
			
			this._disabled = value;
			this.addChild(this.disabled);
		}
		
		protected function get disabled():DisplayObject {
			return this._disabled;
		}
	}
}